<meta charset="UTF-8">
<form action="" method="post">
    数据表名：<input type="text" name="tab">
    <input type="submit" name="sub">
</form>
<?php
include "db.php";
if(!empty($_POST['sub'])){
    $tab=trim($_POST['tab']);
    if(empty($tab)){
        die("表名不能为空");
    }
    if(!empty($_GET['database'])){
        $db=$_GET['database'];
        mysql_select_db($db);
        $sql2=mysql_query("create table $tab (id int,name char(20));",$link);
        if($sql2){
            $sql1=mysql_query("show tables");
            while($b=mysql_fetch_array($sql1)){
                echo "<a style='display: block' href='my.php?database=$db&table=$b[0]'>".$b[0]."</a>";
            }
        }
    }
}
else{
    if(!empty($_GET['database'])){
        $db=$_GET['database'];
        mysql_select_db($db);
        $sql1=mysql_query("show tables");
        while($b=mysql_fetch_array($sql1)){
            echo "<a style='display: block' href='my.php?database=$db&table=$b[0]'>".$b[0]."</a>";
        }
    }

}
